Spawning mechanism
There are two things follow this mechanism, Golden cookie (Wrath Cookie) and Reindeer. They are called shimmers in the game. The spawning mechanism basically is probabilistic, however the probability density function can be approximated nicely by a simple function. This mechanism is also affected by your current FPS (frames per second), which can be changed via cheating. From now on we shall assume the FPS is 30. Let us first ignore the initial Tmin seconds during which the probability of spawning Golden Cookie is 0. There are two basic parameter for shimmers; Tmin and Tmax, and there are many factors in the game can alter these two parametersYou may use the command "Game.shimmerTypes[type].minTime" and "Game.shimmerTypes[type].maxTime" in the console to check the actual value in the game. type can be golden or reindeer and the unit is frame.. For first Tmin seconds, the probability of spawn shimmers is 0. After Tmin seconds every frame, the game checks if a random number between 0 and 1 is less than the proportion of time elapsed and the difference between the maximum and minimum time, taken to the 5th power. Define the test probability at frame n: f_n=\left(\frac{n}{N}\right)^5 Where N=30(Tmax-Tmin) frames is the difference of max time and min time in frame. The probability of spawning the shimmer at frame n''' is: p_n=f_n\Pi_{i=1}^{n-1}\left(1-f_i\right) This means the game failed to spawn from frame 1 to frame '''n-1, but successes at frame n'''. To calculate cumulative density function, which means probability of spawing before frame '''n, we must sum over pn: P_n=\sum_{i=1}^n p_i=1-\Pi_{i=1}^{n}\left(1-f_i\right) When n=N, we have fN=1 and PN=1 which means the shimmer is guaranteed to be spawned before frame N'''. So far everything is exact, and '''n is a discrete integer. We shall approximate n''' as a continuous real number. Notice that: P_n-P_{n-1}=p_n=f_n(1-P_{n-1}) Since the time of each frame is short compared to the maximum time, we may approximate the difference of left hand side as a derivative: P'=f(1-P) This differential equation can be solved normally. The cumulative density function of the cookie spawning at 'k'th frame is: P(k)=1-\exp\left(-\int_0^k f(n)dn\right)=1-\exp\left(\frac{-k^6}{6N^5}\right) We can change the time unit to more familiar second. Let '''k=30t and N=30T, and we have: P(t)=1-\exp\left(\frac{-5t^6}{T^5}\right) and p(t)=P'(t)=\frac{30t^5}{T^5}\exp\left(\frac{-5t^6}{T^5}\right) The resulting cumulative probability of the cookie spawning looks logistic, with the probability early in the range nearly zero but increasing extremely quickly. This function fits well, but fails when t=T=Tmax-Tmin: P(T)=1-\exp(-5T)\neq1 However, it should not be an issue in most cases, since T''' is usually larger than 10 in the game and '''P(T) is extremely close to 1. So far we have ignored first non-spawning Tmin seconds, which means p(t) actually represent the probability of spawning at t+Tmin seconds, not t''' seconds. Let us define a new probability function ''' (t), which represents the probability of spawning at t''' seconds. \bar{p}(t)=\begin{cases}0&T_\text{min}>t\\ p(t-T_\text{min})&T_\text{max}>t\ge T_\text{min}\\ 0&t\ge T_\text{max}\\ \end{cases} Similarly, we can define a new cumulative probability function ''' (t), which represents the probability of spawning before t''' seconds. \bar{P}(t)=\begin{cases}0&T_\text{min}>t\\ P(t-T_\text{min})&T_\text{max}>t\ge T_\text{min}\\ 1&t\ge T_\text{max}\\ \end{cases} It is also convenient to consider the inverse function of ''' (t): \bar{P}^{-1}©=\begin{cases} \left(\frac{-T^5}{5}\ln(1-c)\right)^{\frac{1}{6}}+T_\text{min}&1-\exp(-5T)\ge c> 0\\ T_\text{max}&c> 1-\exp(-5T)\\ \end{cases} The expectation value of spawning time can be obtained: \langle t\rangle=\int_0^\infty t\bar{p}(t)dt\approx T_\text{min}+\int_0^\infty tp(t)dt =T_\text{min}+\left(\frac{T^5}{5}\right)^{\frac{1}{6}}\Gamma\left(\frac{7}{6}\right)\approx T_\text{min}+0.7094497 T^{\frac{5}{6}} Where Γ is the gamma function. Notes Category:Utilities Category:Game Mechanics